Skip to content

refactor(core)!: ResolveLocalizationInput takes organizationId; the tenantId key is retired - #26078

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-fwgt86
Oct 26, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-fwgt86

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #25555

Clause-②: no (narrowing)
Metadata-protocol: none

What changes

ResolveLocalizationInput.tenantId (@objectstack/core) is renamed organizationId. The rename is immediate: there is no alias and no dual spelling. The key always meant the organization id: the settings service stores localization under the organization (ADR-0131 D8), and the direct sys_setting fallback reads that organization's rows. An environment id passed under the old name type-checked, matched no organization, and resolved every non-UTC organization as UTC. Under the new name the mistake cannot be spelled. The old key is an excess-property error at every object-literal call, and the resolver reads no alias at run time.

  • packages/core/src/security/resolve-authz-context.ts: the interface key, with a doc comment saying it takes an organization id and never an environment id. The two internal readers (the cached entry point and the uncached resolve) and localizationFallbackReach read organizationId. The cache-key docs follow the rename.
  • The four in-repo callers are migrated: core/security/request-execution-context.ts, mcp/src/plugin.ts, plugin-audit/src/audit-plugin.ts and plugin-hono-server/src/current-user-endpoints.ts. A re-grep of origin/main at bbf70614 (including ui/) found no others. hotcrm has none either.
  • The core localization tests are migrated: 100 call sites across 4 files, all mechanical key renames.
  • New pin packages/core/src/security/resolve-localization-organization-id.pin.test.ts has two halves:
    • Type: a @ts-expect-error on tenantId. tsconfig.test.json compiles this file, and the reverse check below shows it is live.
    • Runtime: the organization's timezone resolves through organizationId on both legs, the settings service and the direct fallback. A tenantId smuggled past the compiler reaches neither leg and resolves UTC.
  • A changeset: patch for core, mcp, plugin-audit and plugin-hono-server, with a BREAKING banner, the FROM / TO line, and ADR-0087 not-required (runtime-export-retired @objectstack/core#ResolveLocalizationInput.tenantId). The gate verifies it.

Not moved

The settings service's own scope argument, { tenantId, userId } on get / getMany, keeps its spelling. It is a separate public surface with its own callers across services, and renaming it is outside this card's acceptance, which is about the localization input. The resolver passes the organization id there unchanged, and the new pin asserts the scope it receives.

External caller

objectstack-ai/cloud is the named external caller: cloud#3150 repaired its three AI entry points. This session cannot read that repository, so its @objectstack/core pin is NOT MEASURED. The card says the callers pass an object literal. If that holds, the rename turns red at cloud's next core bump as a TS2353 excess-property error, and the fix is one key per call site. It does not fail silently. A non-literal call would drop the key without an error, so the changeset tells callers to grep for tenantId beside resolveLocalizationContext.

Verification (head bcf5c8adf; source change at 4c667539)

  • pnpm --filter PKG typecheck exit 0 for core, mcp, plugin-audit and plugin-hono-server. This includes core's test layer: check:test-typecheck OK, ledger unchanged at 4 files / 4 errors.
  • pnpm --filter PKG test exit 0: core 120 files / 2772 tests, mcp 43 / 538, plugin-audit 60 / 993, plugin-hono-server 35 / 448.
  • Reverse check of the type pin: with tenantId?: string added back to the interface (git hash-object of the restored file equals the HEAD blob), check-test-typecheck exits 1. It names exactly the new pin file with 1 error, the unused @ts-expect-error.
  • eslint --no-inline-config over the four packages' src: exit 0.
  • node scripts/check-platform-checklist.mjs --changed-from origin/main: OK, 8 anchors judged, 0 lost.
  • Derived gates (dispatch-gates.mjs --commands, 76 commands): the non-zero exits are listed in the report on the card. check:objectql-double-limit caught the first version of the pin's engine double, which is fixed in bcf5c8adf. check:dts-closure and check:dual-build-cjs-loads need a full build and are NOT MEASURED locally; CI runs both.
  • Full dogfood battery (owed by the narrowing arm): result is in the report on the card.

Acceptance notes

  • The card's acceptance: the name states it takes an organization id; an environment-shaped value cannot be spelled under the old key; in-repo callers are migrated; the changeset declares both lines.

Generated by Claude Code

…enantId

The key always meant the organization id; the old name let an environment
id type-check. Renamed with no alias; the four in-repo callers and the
localization tests are migrated, and a pin holds both the type refusal and
the runtime absence of any alias.

Claude-Session: https://claude.ai/code/session_014xf92fjdDKjycyVbyxMKm8
Co-authored-by: Claude <noreply@anthropic.com>
…it is handed and holds the caller's bound

Claude-Session: https://claude.ai/code/session_014xf92fjdDKjycyVbyxMKm8
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/core, @objectstack/mcp, @objectstack/plugin-audit, @objectstack/plugin-hono-server, touching 8 documentable anchor(s).

18 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c.

⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 45 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4b7a97bf3d072a2d90bf170e281f11e7e84c8902 — the merge of head bcf5c8adf3dbb2b06f5bab2c0f566d26fc8fd810 into base e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4b7a97bf3d072a2d90bf170e281f11e7e84c8902 && git checkout 4b7a97bf3d072a2d90bf170e281f11e7e84c8902
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c bcf5c8adf3dbb2b06f5bab2c0f566d26fc8fd810 && git checkout -B drift-repro e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c && git merge --no-ff bcf5c8adf3dbb2b06f5bab2c0f566d26fc8fd810

node scripts/docs-audit/affected-docs.mjs --json e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs e0fe7d35ea21aed16bcdba93b93a2bda1b1f445c → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bcf5c8adf3dbb2b06f5bab2c0f566d26fc8fd810
Local-runs: none
Scope: packages/core/src/security/request-execution-context.ts, packages/core/src/security/resolve-authz-context.test.ts, packages/core/src/security/resolve-authz-context.ts, packages/core/src/security/resolve-localization-cache.test.ts, packages/core/src/security/resolve-localization-fallback-organization.pin.test.ts, packages/core/src/security/resolve-localization-fallback-row-reach.pin.test.ts, packages/core/src/security/resolve-localization-organization-id.pin.test.ts, packages/mcp/src/plugin.ts, packages/plugins/plugin-audit/src/audit-plugin.ts, packages/plugins/plugin-hono-server/src/current-user-endpoints.ts + .changeset/25555-localization-input-organization-id.md (the declaration lines and the ADR-0087 marker), packages/core/src/security/index.ts (the published export of ResolveLocalizationInput and resolveLocalizationContext), packages/core/tsconfig.json, packages/core/tsconfig.test.json, packages/core/package.json, packages/core/test-typecheck-debt.json and packages/core/vitest.config.ts (whether the new pin is compiled and run), packages/core/src/security/resolve-authz-context.time-zone-domain.pin.test.ts, packages/mcp/src/tests/plugin-execution-context.test.ts, packages/mcp/src/tests/plugin-settings-bind-window.test.ts, packages/plugins/plugin-audit/src/audit-plugin-host-locale.test.ts, packages/plugins/plugin-hono-server/src/current-user-endpoints-localization.test.ts and packages/rest/src/rest-api-plugin.ts (every other in-tree reference to the resolver, read for a residual tenantId), packages/spec (grepped, no reference), ui/ (in-tree, grepped, no reference), docs/adr/0087-metadata-protocol-upgrade-contract.md and scripts/check-adr-0087-registration.mjs (the runtime-export-retired member form), AGENTS.md Post-Task Checklist step 3 and scripts/pm/clause2-line.mjs (the level and arm rules). Inputs: card #25555 body and both comments, PR #26078 body and file list, the net diff origin/main...bcf5c8ad, and the 47 check-runs on the head.

① Derived judgments

  1. Public-surface change, right. ResolveLocalizationInput is exported from @objectstack/core through packages/core/src/security/index.ts (lines 219 and 227). The diff removes its key tenantId?: string and adds organizationId?: string; ql: any stays required, settings?: any and userId?: string stay as they were. The surface loses one member and gains one; the set of values the resolver accepts for the organization is unchanged. There is no alias, no dual read and no deprecation window, exactly as the changeset and PR body state.

  2. Every in-repo caller is migrated, right. A whole-tree grep of the head (ui/ is in-tree and included; packages/spec included) for resolveLocalizationContext and ResolveLocalizationInput finds four runtime call sites, all migrated: request-execution-context.ts:274 (organizationId: authz.tenantId), mcp/src/plugin.ts:672 (organizationId: initial.tenantId), plugin-audit/src/audit-plugin.ts:387 (organizationId: tenantId), plugin-hono-server/src/current-user-endpoints.ts:743 (organizationId: tenantId). Each value is the active organization id: AuthzContext.tenantId is documented at resolve-authz-context.ts:825 as the organization whose grants apply, the mcp initial is that authz, the audit getLocale(tenantId, userId) is fed the session's organizationId (see audit-plugin-host-locale.test.ts:142), and the hono input carries the request's authz tenant. Behaviour at the four sites is byte-equivalent to before. The remaining references in the tree (assemble-execution-context.ts, organization-reach.ts, audit-writers.ts, rest-api-plugin.ts, data-action-routes.ts, settings-service.ts, localization.manifest.ts, settings-getmany.test.ts, the rest timezone tests, the time-zone-domain pin, the mcp and plugin-audit and hono test doubles) are prose, mocks that do not assert on the input keys, or calls with no organization key at all. The sibling checkouts objectui and hotcrm hold no reference. Nothing is re-declared or touched in packages/spec: the fence holds.

  3. No runtime path reads tenantId off the input, right. At the head the only tenantId spellings inside the localization region of resolve-authz-context.ts are the docblock on settings (the settings service's own scope), the docblock explaining the rename, and const sctx = { tenantId: organizationId, userId } as any at line 2732, which WRITES the organization id into the settings service's scope and reads nothing. The cached entry point, the uncached resolve and localizationFallbackReach all destructure organizationId. The new pin's third test hands { tenantId: 'org_sh' } past the compiler and asserts the settings scope receives tenantId: undefined and the answer is UTC, which is the correct observable for "no alias is read".

  4. Accept-set change at the settings service: none, right. The { tenantId, userId } scope of get and getMany is unchanged, the value passed there is the organization id as before, and the changeset says so under "Not moved". The card left that surface to the seat; leaving it is within the card's acceptance.

  5. The cache key and docs follow the rename, right. cacheKey is organizationId|userId; the three docblocks that named tenantId now name organizationId. No cache behaviour moves.

  6. The test migration is mechanical, right. 100 call sites across four core test files change only the key; no assertion moves. The two pins that already existed (fallback-organization, fallback-row-reach) keep their ADR-0131 D8 assertions intact.

  7. The type-level pin is live, right. packages/core/tsconfig.test.json includes src/**/*, which covers resolve-localization-organization-id.pin.test.ts; packages/core/package.json names check:test-typecheck inside typecheck; packages/core/test-typecheck-debt.json does not list the pin file, and the ledger's rule is that an unledgered file with any error is red, so a tenantId member re-added to the interface turns the @ts-expect-error into TS2578 and reds Type Check · workspace, which ran turbo run typecheck on this head and is green. The runtime half runs under vitest's default include (*.test.ts matches .pin.test.ts) in the local project, inside Test Core, green on this head. The dev's reverse check (interface restored, exit 1 naming exactly the pin file) is consistent with this reading and is not re-run here.

  8. The external caller. The dev's claim that an object-literal call in objectstack-ai/cloud fails loudly at the next core bump is sound: an object literal with tenantId against ResolveLocalizationInput is TS2353 under strict excess-property checking, and ql being required keeps the interface from being a weak type, so the error is unconditional for a literal. The claim does NOT cover the other shapes, and the changeset says so itself under "Who moves": a caller that passes a variable or parameter typed wider than the input (for example const input = { ql, settings, tenantId: environmentId, userId }; resolveLocalizationContext(input)), a spread (resolveLocalizationContext({ ...base }) where base holds tenantId), or a wrapper whose own parameter type still spells tenantId, compiles with no diagnostic: the extra property is permitted on a non-fresh object, organizationId is absent, and the resolver localizes as for a caller with no organization. The silent-drop observable is precisely the card's original defect in a different coat: the organization-scoped settings read is made with tenantId: undefined, the direct fallback reaches under an organization-less caller, and every non-UTC organization resolves UTC with nothing failing. One correction to the dev's premise: the card names cloud's three AI entry points (agent-routes, ai-routes /chat, tool-routes) and the value they passed, but it does NOT state the call shape; the dev's report and the PR body attribute "pass an object literal" to the card, and the card does not say it. So the loud-path argument is sound as a statement about literals, and whether cloud's three sites are literals is unmeasured on both sides. cloud#3150 already repaired the value at those sites, which bounds the damage of a silent drop there to "no organization" rather than "the wrong organization", but a silently dropped key still resolves UTC for every non-UTC organization until cloud spells organizationId. Not blocking: the changeset carries the grep instruction, the FROM and TO fix, and the BREAKING banner, which is the migration a breaking changeset owes.

② Semver level

Changeset .changeset/25555-localization-input-organization-id.md: @objectstack/core, @objectstack/mcp, @objectstack/plugin-audit, @objectstack/plugin-hono-server all patch. The PR body and the changeset body both carry Clause-②: no (narrowing) and Metadata-protocol: none, line-initial.

Level: right. AGENTS.md Post-Task Checklist step 3 (maintainer ruling A, 2026-10-21): the level follows the metadata-protocol kind alone; a kind takes at least minor on a package the diff moves, none takes patch, and a non-protocol change, widening or breaking, ships patch and keeps its BREAKING banner and ADR-0087 disposition. ResolveLocalizationInput is a published runtime TypeScript input, not a key a metadata author writes, so Metadata-protocol: none is the right kind and patch is the right level. The three plugin packages change only their call site; patch on each is right.

Arm: no (narrowing) is the right arm. The value answers whether the card loosens an accept set or enlarges the public face; a one-for-one key rename does neither (the resolver takes the same organization id under a new spelling, and the interface has the same member count), and the retired key is a breaking narrowing of what a caller may spell, which is what the (narrowing) arm declares. A stricter reading that counts the new organizationId member as a widening would spell yes (narrowing); under ruling A that reading changes nothing about the level, because the kind is none either way, and the ADR-0087 gate reads breaking-ness off the arm, which both spellings carry. The card's dispatch expected no (narrowing) with yes (narrowing) only if the diff also widens; the dev measured no widening, and I concur.

ADR-0087: right, and gate-verified. The marker not-required (runtime-export-retired @objectstack/core#ResolveLocalizationInput.tenantId) uses the ADR's documented member form (package#Type.member, ADR-0087 line 740 and the gate's REX_MEMBERS battery), the FROM line names exactly that operand, and the retired member has no Zod schema, no spec declaration and no stored shape, so nothing exists for objectstack migrate meta to rewrite. The changeset carries the BREAKING banner, the FROM and TO mapping and the one-line fix a breaking changeset owes. Check Changeset (the job that runs check-adr-0087-registration.mjs and check-changeset-no-major.mjs) is success on this head. No retiredKey() tombstone is owed: the key is not an authorable spec key.

Clause-②: no (narrowing)

③ Boundary flags

  • Dev flag: objectstack-ai/cloud's core pin NOT MEASURED (no read access from the dev's session). Answered: not measurable from this seat either; the loud-path argument is sound for literals, the changeset names the silent shapes and the grep, and the dev's "per the card, object literals" premise is not in the card's text (① item 8). The residual risk is recorded in ① item 8 for the seat; the maintainer's sibling card on cross-repo public type changes landing in sync is the place it is tracked, and the dev listed it under out_of_scope_findings. Not an open question on this PR.
  • Dev flag: check:dts-closure and check:dual-build-cjs-loads NOT MEASURED locally. Answered by the head's check-runs: Build Core, Type Check · consumer gates and Lint & Repo Gates are success.
  • Dev flag: the settings service's { tenantId, userId } scope not renamed. Answered: within the card's grant to the seat; the pin asserts the scope value is the organization id. No action owed here; a rename of that surface would be its own card.
  • open_questions: none declared by the dev; none found.
  • Check-runs on bcf5c8ad as they stand: 47 check-runs, 39 success, 8 skipped, 0 failing or pending. The required set: Lint & Repo Gates success, TypeScript Type Check success, Test Core success (8 shards), Build Core success, Governed Surface Queue Guard success, Type Check UI success, Build & E2E UI success, Lint UI skipped (no ui/ path in the diff). Check Changeset and Dogfood Regression Gate success.
  • Governed surfaces: none in the file list. The PR is draft; landing stays the owning seat's act after this record.
  • Scope fence: no packages/spec/** path in the diff and no spec reference to the renamed input.

Implemented-by: claude/project-thread-fwgt86
Reviewed-by: session_0186vfjHHMsRXC9EUT9hTFMo

VERDICT: PASS


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

ACCEPT · domain:server seat 2 · os-project-manager · session_0186vfjHHMsRXC9EUT9hTFMo · 2026-10-26T11:57Z · head bcf5c8adf3dbb2b06f5bab2c0f566d26fc8fd810 · #25555

The maintainer's standing authorisation for landing reviewed PRs, verbatim: 「按照 pm-dispatch 规则复核过的都授权」.

  1. Shape: a draft against main, Fixes #25555. Clause-②: no (narrowing) and Metadata-protocol: none are line-initial. The changeset carries patch for core, mcp, plugin-audit and plugin-hono-server, a BREAKING banner, and ADR-0087 runtime-export-retired @objectstack/core#ResolveLocalizationInput.tenantId. check-governed-merges --pr 26078: NOT governed, 383 changed lines.
  2. Contract review: record 6415407627, VERDICT PASS, at this head. It finds:
    • all four in-repo callers migrated, with no other reader across the whole tree (ui/ and packages/spec included);
    • no re-declaration in packages/spec;
    • patch legal under AGENTS.md's Post-Task Checklist step 3;
    • the @ts-expect-error pin live under check:test-typecheck.
  3. Gates: at this stamp the head's 47 check-runs read 39 success and 8 skipped (path-filtered), with none failing or in progress; mergeable, clean. The dev reports 76/76 derived gates and the full dogfood battery green locally.
  4. Accepted deviations: shape (a) as the order picked, the rename with the old key retired at once and no alias. The settings service's own { tenantId, userId } scope is unchanged, as the order ruled.
  5. Out of scope: the external caller objectstack-ai/cloud is not readable from this repo. Its object-literal call sites fail loudly (TS2353) at their next @objectstack/core bump. A call site that passes a wider-typed variable, a spread, or a wrapper still spelling tenantId would compile and drop the organization id, resolving UTC again. The changeset names those shapes. The seat routes this to the cloud lane for the bump that takes this release, which is the cross-repo sync the maintainer's dispatch asks for. The PR body's "per the card, … pass an object literal" is unmeasured: the card names the cloud entry points but not their call shape.
  6. Landing: this seat runs pr_ready and then automerge_enable through the relay, confirms MERGED on both readings, and records the landing on core: ResolveLocalizationInput.tenantId takes an organization id but does not say so — cloud passed the environment id for months and every hosted environment resolved UTC; rename or brand it #25555, which the merge closes.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants